<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use function MongoDB\BSON\toJSON;

class  Bmi extends Model
{
    public $table = 'user_bmi';
    public $timestamps = false;

    public function selectMainBmi($user_id)
    {
        $bmi = $this->where('user_id',$user_id)->where('initial',1) ->first();
        if (is_null($bmi)) {
            return false;
        } else {
            $bmi = $bmi->toArray();
        }
        return $bmi;
    }
    public function updataBmi($data,$userId)
    {
        $map = [
            'user_id' => $userId,
            'initial' => 1
        ];
//        echo $data.toJSON();
//        return $data;
        return $this ->where($map) ->update($data);
    }

}